
var dao = require("DataDao");

module.exports = {
    heroBuffer:[],//初始带入buffer
    heroSkill:[0,1,2,3,4],
    // heroSkillLevel:[11,5,5,5,20],
    curMode:2,//随机模式 2 关卡模式
    curlevel:1,//关卡等级
    curEnemySwapIndex:0,//当前刷新的敌人
    curLevelConfig:null,//当前等级地图配置
    config:null,
    // configConst:null,//通用常量
    levelOther:null,
    growUp:null,
    skillConfig:null,//技能升级表
    // playDao:null,
    goldConfig:null,//金币图标


    // heroWeight:0,
    transformTime:function(num){
        let hour = Math.floor(num / (3600000));
        let minute = Math.floor((num - hour * 3600000)/60000);
        let second = Math.floor((num - hour * 3600000 - minute * 60000)/1000)

        return (hour + "时" + minute + "分" + second + "秒")
    },
    getSkillUp:function (id)
    {
        if(this.growUp == null)
        {
            this.growUp = require("../config/growUp");
        }

        if(this.skillConfig == null)
        {
            this.skillConfig = this.growUp.skillConfig; 
        }

        return this.skillConfig[id];

    },
    // getConstConfig:function(){
    //     if( this.configConst ==null)
    //         this.configConst = require("../config/configConst").configConst;
    //     return this.configConst[0];
    // },
    getHeroWeight:function()
    {
        // return this.getConstConfig().heroWeight;
        return dao.getWeight();
    },
    getPlayer:function(){
        return dao.getPlayer();
    },

    getLevelOtherConfig:function(id)
    {
        if( this.levelOther == null)
            this.levelOther = require("../config/levelOther").levelOther;
        return this.levelOther[id];
    },
//初始化global
    initLevelConfig:function(){
        // var playDao = require("../dao/playDao");
        // playDao = playDao.loadPlayDate(playDao);


        this.heroSkill = dao.playSkill;
        // this.heroSkillLevel = dao.playSkillLevel;
        // this.curlevel = playDao.curLevel;
        this.curlevel = dao.getCurrentLevel();
        // if(this. getConstConfig().curLevel !=-1  )
        // {
        //     this.curlevel ;
        // }
        // this. playDao = playDao;

       // if(this.curLevelConfig == null){

            var nameExtend = (this.curlevel -1)/10;

            nameExtend = Math.floor(nameExtend);
            var p = "Level"+nameExtend;
            this.config  = require(p); //读表
        
            

            this.curLevelConfig = this.config["map" +this.curlevel ];
       // }
        this.curEnemySwapIndex = 0;
    },
    ReLeveRlConfig:function(){
        var nameExtend = (this.curlevel -1)/10;
        nameExtend = Math.floor(nameExtend);
        this.config  = require("Level" + nameExtend); //读表

        this.curLevelConfig = this.config["map" +this.curlevel ];
        this.curEnemySwapIndex = 0;
    },
    getLevelConfig:function () {
        if(this.curLevelConfig == null)
        {
            this.curLevelConfig = this.config["map" +this.curlevel ];
        }
        return this.curLevelConfig;
    },
    getGoldConfig:function()
    {
        if(this.growUp == null)
        {
            this.growUp = require("../config/growUp");
        }

        if(this.goldConfig == null)
        {
            this.goldConfig =this.growUp.levelGold;
        }
        return this.goldConfig;
    }

}

